<template>
	<view class="content">
		<button @click="navigateToPlugin">点击跳转插件页2</button>
		<!-- <button @click="login">登录</button> -->
		<button @click="next">打开redirect</button>

	</view>
</template>

<script>
	import {loginByCode} from '@/api/api.js'
	export default {
		components: {},
		data() {
			return {
				title: 'hello',
				test: false
			}
		},
		methods: {
			navigateToPlugin() {
				console.log('2145215')
				uni.navigateTo({
					url: "plugin://myPlugin/guess?id=62e9e05cc70ad&type=guess&plugin=scratchcard"
				});

			},
			aaa() {
				uni.showToast({
					title: '收到'
				})
			},
			login() {
				// #ifdef MP-WEIXIN
				// 登录
				// wx.login({
				// 	success: res => {
				// 		console.log("code is : ",res.code);
				// 		// loginByCode({code: res.code}).then(userInfo=>{
				// 		// 	console.log('userinfo is : ',userInfo)
				// 		 //    wx.setStorageSync('currentUser',Object.assign(wx.getStorageSync('currentUser'),{openId:userInfo.data.openId}))
				// 			// resolve(Object.assign(wx.getStorageSync('currentUser'),{openId:userInfo.data.openId}))
				// 		})
				// 	}
				// })
				// #endif
			},
			next(){
				let pages = getCurrentPages(); // 获取页面指针数组
				let currentPage = pages[pages.length - 1]; // 获取当前页
				console.log(decodeURIComponent(currentPage.options.redirect));
				uni.navigateTo({
					url: decodeURIComponent(currentPage.options.redirect)
				});
			}
		},
		mounted() {
			console.log('%clogin Fuction 请在plugin.js中完善',"color:orange")
			// var pages = getCurrentPages(); // 获取页面指针数组
			// var currentPage = pages[pages.length - 1]; // 获取当前页
			// console.log(encodeURI(currentPage.options.redirect));
		}
	};
</script>

<style>
	.content {
		text-align: center;
		height: 400upx;
	}

	.logo {
		height: 200upx;
		width: 200upx;
		margin-top: 200upx;
	}

	.title {
		font-size: 36upx;
		color: #8f8f94;
	}
</style>
